#!/bin/bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/script-kubernetes/centos7-install-k8s-master.sh | /bin/bash
#
#
############################################################################

#安装epel源（阿里云加速节点）
tee /etc/yum.repos.d/epel.repo <<EOF
[epel]
name = epel
baseurl = https://mirrors.aliyun.com/epel/7/x86_64/
enabled = 1
gpgcheck = 0

EOF


#安装k8s源（阿里云杭州加速节点）
tee /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name = Kubernetes Repository
baseurl = http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled = 1
gpgcheck = 0

EOF


yum clean all
yum makecache
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes


(curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos7-install-docker.sh | /bin/bash)


echo "设定开机启动，并重启docker和kubelet"
systemctl enable docker && systemctl restart docker
systemctl enable kubelet && systemctl restart kubelet

echo "关闭swap分区"
swapoff  -a
sed -ri 's/.*swap.*/#&/' /etc/fstab

#主机名需要自己在终端手动去配置好



#下面注释掉，这样一来master和node节点都可以使用该脚本了
#kubeadm config print init-defaults > ~/config.yaml
